//https://leetcode-cn.com/problems/maximum-number-of-balloons/
package main

import "fmt"

func maxNumberOfBalloons(text string) int {
	b, a, l, o, n := 0, 0, 0, 0, 0

	for _, v := range text {
		if v == 'a' {
			a++
		} else if v == 'b' {
			b++
		} else if v == 'l' {
			l++
		} else if v == 'o' {
			o++
		} else if v == 'n' {
			n++
		}
	}
	if b < a {
		a = b
	}
	if l/2 < a {
		a = l / 2
	}

	if o/2 < a {
		a = o / 2
	}
	if n < a {
		a = n
	}
	return a
}

func main() {
	fmt.Println(maxNumberOfBalloons("nlaebolko"))
	fmt.Println(maxNumberOfBalloons("loonbalxballpoon"))
	fmt.Println(maxNumberOfBalloons("leetcode"))
}
